#!/bin/bash
# Simple script to list version numbers of critical development tools

export LC_ALL=C

echo	"--------------------------------"
echo	""
echo	"    Host System Requirements    "
echo	"  (press RETURN to scroll down) "
echo	""
echo	"--------------------------------"
echo	""
echo	"..................................."
echo	"bash"
echo	"- on this system:"
bash --version | head -n1 | cut -d" " -f2-4
echo "/bin/sh -> `readlink -f /bin/sh`"
echo	"- required: Bash-3.2"
echo	""
echo	""
echo	"..................................."
echo	"Binutils"
echo -n "- on this system: "; ld --version | head -n1 | cut -d" " -f3-
echo	"- required: Binutils-2.17 (Versions greater than 2.22 are not recommended as they have not been tested) "
echo	""
echo	""
echo	"..................................."
echo	"bison"
echo	"- on this system:"
bison --version | head -n1
if [ -e /usr/bin/yacc ];
  then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; 
  else echo "yacc not found"; fi
echo	"- required: Bison-2.3 (/usr/bin/yacc should be a link to bison or small script that executes bison)"
echo	""
echo	""
echo	"..................................."
echo	"bzip2"
echo	"- on this system:"
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6-
echo	"- required: Bzip2-1.0.4"
echo	""
echo	""
echo	"..................................."
echo	"Coreutils"
echo	"- on this system:"
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2
echo	"- required: Coreutils-6.9"
echo	""
echo	""
echo	"..................................."
echo	"diff"
echo	"- on this system:"
diff --version | head -n1
echo	"- required: Diffutils-2.8.1"
echo	""
echo	""
echo	"..................................."
echo	"Findutils"
echo	"- on this system:"
find --version | head -n1
echo	"- required: Findutils-4.2.31"
echo	""
echo	""
echo	"..................................."
echo	"gawk"
echo	"- on this system:"
gawk --version | head -n1
if [ -e /usr/bin/awk ];
  then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; 
  else echo "awk not found"; fi
echo	"- required: Gawk-3.1.5 (/usr/bin/awk should be a link to gawk) "
echo	""
echo	""
echo	"..................................."
echo	"gcc"
echo	"- on this system:"
gcc --version | head -n1
echo	"- required: Gcc-4.1.2 (Versions greater than 4.7.2 are not recommended as they have not been tested) "
echo	""
echo	""
echo	"..................................."
echo	"Glibc"
echo	"- on this system:"
ldd --version | head -n1 | cut -d" " -f2-  # glibc version
echo	"- required: Glibc-2.5.1 (Versions greater than 2.16.0 are not recommended as they have not been tested) "
echo	""
echo	""
echo	"..................................."
echo	"Grep"
echo	"- on this system:"
grep --version | head -n1
echo	"- required: Grep-2.5.1a"
echo	""
echo	""
echo	"..................................."
echo	"Gzip"
echo	"- on this system:"
gzip --version | head -n1
echo	"- required: Gzip-1.3.12"
echo	""
echo	""
echo	"..................................."
echo	"Linux Kernel"
echo	"- on this system:"
cat /proc/version
echo	"- required: Linux Kernel-2.6.25 (having been compiled with GCC-4.1.2 or greater) "
echo	""
echo	""
echo	"..................................."
echo	"M4"
echo	"- on this system:"
m4 --version | head -n1
echo	"- required: M4-1.4.10"
echo	""
echo	""
echo	"..................................."
echo	"Make"
echo	"- on this system:"
make --version | head -n1
echo	"- required: Make-3.81"
echo	""
echo	""
echo	"..................................."
echo	"Patch"
echo	"- on this system:"
patch --version | head -n1
echo	"- required: Patch-2.5.4"
echo	""
echo	""
echo	"..................................."
echo	"Perl"
echo	"- on this system:"
echo `perl -V:version`
echo	"- required: Perl-5.8.8"
echo	""
echo	""
echo	"..................................."
echo	"Sed"
echo	"- on this system:"
sed --version | head -n1
echo	"- required: Sed-4.1.5"
echo	""
echo	""
echo	"..................................."
echo	"Tar"
echo	"- on this system:"
tar --version | head -n1
echo	"- required: Tar-1.18"
echo	""
echo	""
echo	"..................................."
echo	"Texinfo"
echo	"- on this system:"
echo "Texinfo: `makeinfo --version | head -n1`"
echo	"- required: Texinfo-4.9"
echo	""
echo	""
echo	"..................................."
echo	"Xz"
echo	"- on this system:"
xz --version | head -n1
echo	"- required: Xz-5.0.0"
echo	""
echo	""
echo	"..................................."
echo	"Testing ability to build a program"
echo 'main(){}' > dummy.c && gcc -o dummy dummy.c
if [ -x dummy ] 
  then echo "- gcc compilation OK";
  else echo "- gcc compilation FAILED"; fi
rm -f dummy.c dummy
echo	""
echo	""
echo	"..................................."










